<html>
<head>
    <meta name="layout" content="freshmade">
</head>

<body>

<div id="content-wrapper">
    <div class="center-wrapper">
        <div class="content">
            <div id="main">
                <div class="post">
                    <div class="post-title">
                        <h1>${project.name}</h1>
                        <g:render template="/template/messageBar"/>
                    </div>

                    <div class="post-button">
                        <g:if test="${params.config}">
                            <g:link action="show" id="${params.id}" class="myform-linkbutton">
                                Finish Config
                            </g:link>
                        </g:if>
                        <g:else>
                            <g:link action="show" id="${params.id}" params="[config: true]" class="myform-linkbutton">
                                Config
                            </g:link>
                        </g:else>
                        <g:render template="/template/editdelete"/>
                    </div>

                    <div class="post-date">
                        <g:render template="/template/createdBy2" model="[trace: project]"/>
                    </div>
                </div>

                <div id="myform">
                    <div class="field">
                        <div class="key2"><g:message code="project.comment"/></div>

                        <div class="value">
                            ${project.comment}
                        </div>

                        <div class="clear"></div>
                    </div>

                    <div class="field">
                        <div class="key2"><g:message code="project.share"/></div>

                        <div class="value">
                            <g:each in="${project.proUsers}" var="it" status="i">
                                <g:link controller="user" action="showPart" id="${it.user.id}">${it.user.name}</g:link>
                                <tmpl:configDelete controller='proUser' id="${it.id}"/>
                                <tmpl:configSplit x="${i}" size="${project.proUsers.size()}"/>
                            </g:each>
                            <tmpl:configAdd controller='proUser' id="${project.id}"/>
                        </div>

                        <div class="clear"></div>
                    </div>
                </div>

                <br/>

                <div class="post">
                    <div class="post-title"><h3><g:message code="project.relationship"/></h3></div>

                    <div class="post-body">
                        Total ${comSize} ${comSize > 1 ? 'companies' : 'company'}
                        and ${empSize} ${empSize > 1 ? 'employees' : 'employee'}
                        in this project
                    </div>
                </div>
                <table class="data-table">
                    <tr>
                        <th><g:message code="proCompany.role"/></th>
                        <th><g:message code="proCompany.company"/></th>
                        <th><g:message code="proEmployee.employee"/></th>
                    </tr>
                    <tbody>
                    <g:each in="${project.proCompanies}" var="proCom" status="i">
                        <tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
                            <td>${proCom.role}</td>
                            <td>${proCom.company.name}<tmpl:configDelete controller='proCompany'
                                                                         id="${proCom.id}"/></td>
                            <td>
                                <g:each in="${proCom.proEmployees}" var="proEmp" status="j">
                                    ${proEmp.employee.name}<tmpl:configDelete controller='proEmployee'
                                                                              id="${proEmp.id}"/>
                                    <tmpl:configSplit x="${j}" size="${proCom.proEmployees.size()}"/>
                                </g:each>
                                <tmpl:configAdd controller='proEmployee' id="${proCom.id}"/>
                            </td>
                        </tr>
                    </g:each>
                    <g:if test="${params.config}">
                        <tr>
                            <td></td>
                            <td><tmpl:configAdd controller='proCompany' id="${project.id}"/></td>
                            <td></td>
                        </tr>
                    </g:if>
                    </tbody>
                </table>

                <div class="clearer">&nbsp;</div>

                <div class="post">
                    <div class="post-title"><h3><g:message code="task.report"/></h3></div>

                    <div class="post-date">
                        <g:render template="/template/listBar2" model="[size: project.tasks.size()]"/>
                        | <g:link controller="task" action="create" id="${project.id}">Add Task...</g:link>
                    </div>

                </div>

                <div class="comment-list">
                    <g:each in="${project.tasks}" var="task">
                        <div class="comment">
                            <div class="comment-gravatar left">
                                <g:img file="freshmade/sample-gravatar.jpg" height="32" width="32"/>
                            </div>

                            <div class="comment-author left">
                                ${task.createdBy.name}
                                <div class="comment-date">Task Date:
                                    <g:formatDate date="${task.finishedDate}" formatName="date.withoutTime"/>
                                    | Submit Date: <g:formatDate date="${task.dateCreated}"/></div>
                            </div>

                            <div class="clearer">&nbsp;</div>

                            <div class="comment-body">
                                <p>${task.content}</p>

                                <p>
                                    <g:link controller="task" action="edit" id="${task.id}">Edit</g:link>
                                    | <g:link controller="task" action="delete" id="${task.id}">Delete</g:link>
                                </p>
                            </div>

                        </div>
                    </g:each>

                </div>

            </div>

            <div class="clearer">&nbsp;</div>
        </div>

    </div>
</div>

</body>
</html>